package com.ruoyi.common.entity.system;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.ruoyi.common.entity.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.util.ArrayList;
import java.util.List;

/**
 * 部门表 sys_dept
 * 
 * @author LiuXiaoYu
 */
@EqualsAndHashCode(callSuper = true)
@Data
@AllArgsConstructor
@NoArgsConstructor
public class SysDept extends BaseEntity {
    private static final long serialVersionUID = 1L;

    /** 部门ID */
    @TableId(value = "dept_id",type = IdType.AUTO)
    private Long deptId;

    /** 父部门ID */
    @TableField(value = "parent_id")
    private Long parentId;

    /** 祖级列表 */
    @TableField(value = "ancestors")
    private String ancestors;

    /** 部门名称 */
    @TableField(value = "dept_name")
    @NotBlank(message = "部门名称不能为空")
    @Size(max = 30, message = "部门名称长度不能超过30个字符")
    private String deptName;

    /** 显示顺序 */
    @TableField(value = "order_num")
    @NotBlank(message = "显示顺序不能为空")
    private String orderNum;

    /** 负责人 */
    @TableField(value = "leader")
    private String leader;

    /** 联系电话 */
    @TableField(value = "phone")
    @Size(max = 11, message = "联系电话长度不能超过11个字符")
    private String phone;

    /** 邮箱 */
    @TableField(value = "email")
    @Email(message = "邮箱格式不正确")
    @Size(max = 50, message = "邮箱长度不能超过50个字符")
    private String email;

    /** 部门状态:0正常,1停用 */
    @TableField(value = "status")
    private String status;

    /** 父部门名称 */
    @TableField(exist = false)
    private String parentName;
    
    /** 子部门 */
    @TableField(exist = false)
    private List<SysDept> children = new ArrayList<>();

}
